@use "../core/color";
@use "../core/layout";
@use "../core/typography";

@mixin tooltip-arrow($rotation) {
  background: color.$grey-7;
  border-bottom: 1px solid rgba(0,0,0,0.20);
  border-right: 1px solid rgba(0,0,0,0.20);
  content: "";
  display: none;
  height: 6px;
  left: 0;
  margin-left: auto;
  margin-right: 7px;
  position: absolute;
  right: 0;
  transform: rotate($rotation);
  width: 6px;

  .env-js-capable & {
    display: block;
  }

  .env-js-timeout & {
    display: none;
  }
}

.tooltip {
  @include typography.font-small;

  // Override the opacity set by Bootstrap's "tooltip" class when this component
  // is used in /admin pages. The rest of the site does not use Bootstrap.
  opacity: initial;

  border-radius: 2px;
  background-color: color.$grey-7;
  color: white;
  display: none;
  font-style: normal;
  padding-left: 5px;
  padding-right: 5px;
  padding-top: 4px;
  padding-bottom: 4px;
  position: absolute;
  left: calc(100% - 12px);
  width: 220px;
  z-index: layout.$zindex-tooltip;

  .env-js-capable & {
    display: block;
  }

  .env-js-timeout & {
    display: none;
  }
}

// Arrow at the bottom of the tooltip pointing down at the target element.
.tooltip:before {
  @include tooltip-arrow(45deg);
  content: "";
  top: calc(100% - 5px);
  right: calc(100% - 16.5px);
}

.tooltip-label {
  // Make the label a positioned element so that it appears _above_ the
  // tooltip's arrow, which partially overlaps the content of the tooltip.
  position: relative;
}
